<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>统计报表 - 管理员后台</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        .admin-header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 2rem 0;
        }
        .stat-card {
            border: none;
            border-radius: 15px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease;
            margin-bottom: 2rem;
        }
        .stat-card:hover {
            transform: translateY(-5px);
        }
        .stat-icon {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            margin-bottom: 1rem;
        }
        .icon-movies { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
        .icon-showtimes { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: white; }
        .icon-users { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); color: white; }
        .icon-orders { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); color: white; }
        
        .stat-number {
            font-size: 2.5rem;
            font-weight: bold;
            color: #333;
        }
        .stat-label {
            color: #666;
            font-size: 0.9rem;
        }
        .chart-container {
            background: white;
            border-radius: 15px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            padding: 2rem;
            margin-bottom: 2rem;
        }
    </style>
</head>
<body class="bg-light">
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);">
        <div class="container">
            <a class="navbar-brand fw-bold" href="${pageContext.request.contextPath}/admin/">
                <i class="fas fa-cog me-2"></i>管理员后台
            </a>
            
            <div class="navbar-nav ms-auto">
                <!-- 主要管理功能 -->
                <a class="nav-link" href="${pageContext.request.contextPath}/admin/movies">
                    <i class="fas fa-film me-1"></i>电影管理
                </a>
                <a class="nav-link" href="${pageContext.request.contextPath}/admin/showtimes">
                    <i class="fas fa-calendar-alt me-1"></i>场次管理
                </a>
                <a class="nav-link" href="${pageContext.request.contextPath}/movies">
                    <i class="fas fa-home me-1"></i>前台首页
                </a>
                
                <!-- 用户菜单 -->
                <div class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
                        <i class="fas fa-user me-1"></i>${sessionScope.user.username}
                    </a>
                    <ul class="dropdown-menu">
                        <li><a class="dropdown-item" href="${pageContext.request.contextPath}/admin/statistics">
                            <i class="fas fa-chart-bar me-2"></i>统计报表
                        </a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" href="${pageContext.request.contextPath}/logout">
                            <i class="fas fa-sign-out-alt me-2"></i>退出登录
                        </a></li>
                    </ul>
                </div>
            </div>
        </div>
    </nav>

    <!-- 管理员头部 -->
    <section class="admin-header">
        <div class="container">
            <h2><i class="fas fa-chart-bar me-2"></i>统计报表</h2>
            <p class="mb-0">系统运营数据统计和分析</p>
        </div>
    </section>

    <div class="container mt-4">
        <!-- 错误信息 -->
        <c:if test="${not empty error}">
            <div class="alert alert-danger" role="alert">
                <i class="fas fa-exclamation-triangle me-2"></i>${error}
            </div>
        </c:if>

        <!-- 核心统计数据 -->
        <h5 class="mb-4"><i class="fas fa-tachometer-alt me-2"></i>核心数据</h5>
        <div class="row">
            <!-- 电影总数 -->
            <div class="col-lg-3 col-md-6 mb-4">
                <div class="card stat-card">
                    <div class="card-body text-center">
                        <div class="stat-icon icon-movies mx-auto">
                            <i class="fas fa-film"></i>
                        </div>
                        <div class="stat-number">${statistics.totalMovies}</div>
                        <div class="stat-label">电影总数</div>
                    </div>
                </div>
            </div>

            <!-- 今日场次 -->
            <div class="col-lg-3 col-md-6 mb-4">
                <div class="card stat-card">
                    <div class="card-body text-center">
                        <div class="stat-icon icon-showtimes mx-auto">
                            <i class="fas fa-calendar-alt"></i>
                        </div>
                        <div class="stat-number">${statistics.todayShowtimes}</div>
                        <div class="stat-label">今日场次</div>
                    </div>
                </div>
            </div>

            <!-- 用户总数 -->
            <div class="col-lg-3 col-md-6 mb-4">
                <div class="card stat-card">
                    <div class="card-body text-center">
                        <div class="stat-icon icon-users mx-auto">
                            <i class="fas fa-users"></i>
                        </div>
                        <div class="stat-number">${statistics.totalUsers}</div>
                        <div class="stat-label">注册用户</div>
                    </div>
                </div>
            </div>

            <!-- 今日订单 -->
            <div class="col-lg-3 col-md-6 mb-4">
                <div class="card stat-card">
                    <div class="card-body text-center">
                        <div class="stat-icon icon-orders mx-auto">
                            <i class="fas fa-shopping-cart"></i>
                        </div>
                        <div class="stat-number">${statistics.todayOrders}</div>
                        <div class="stat-label">今日订单</div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 详细统计 -->
        <h5 class="mb-4"><i class="fas fa-chart-line me-2"></i>详细统计</h5>
        <div class="row">
            <div class="col-md-6">
                <div class="chart-container">
                    <h6><i class="fas fa-film me-2"></i>电影状态分布</h6>
                    <div class="row text-center mt-3">
                        <div class="col-6">
                            <div class="h4 text-success">${statistics.nowShowingMovies}</div>
                            <small class="text-muted">正在上映</small>
                        </div>
                        <div class="col-6">
                            <div class="h4 text-warning">${statistics.comingSoonMovies}</div>
                            <small class="text-muted">即将上映</small>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="col-md-6">
                <div class="chart-container">
                    <h6><i class="fas fa-calendar me-2"></i>场次统计</h6>
                    <div class="row text-center mt-3">
                        <div class="col-6">
                            <div class="h4 text-primary">${statistics.totalShowtimes}</div>
                            <small class="text-muted">总场次数</small>
                        </div>
                        <div class="col-6">
                            <div class="h4 text-info">${statistics.todayShowtimes}</div>
                            <small class="text-muted">今日场次</small>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-6">
                <div class="chart-container">
                    <h6><i class="fas fa-user-plus me-2"></i>用户增长</h6>
                    <div class="row text-center mt-3">
                        <div class="col-6">
                            <div class="h4 text-primary">${statistics.totalUsers}</div>
                            <small class="text-muted">总用户数</small>
                        </div>
                        <div class="col-6">
                            <div class="h4 text-success">${statistics.weeklyNewUsers}</div>
                            <small class="text-muted">本周新增</small>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="col-md-6">
                <div class="chart-container">
                    <h6><i class="fas fa-chart-pie me-2"></i>系统概览</h6>
                    <div class="mt-3">
                        <div class="d-flex justify-content-between mb-2">
                            <span>电影管理</span>
                            <a href="${pageContext.request.contextPath}/admin/movies" class="btn btn-sm btn-outline-primary">
                                <i class="fas fa-arrow-right"></i>
                            </a>
                        </div>
                        <div class="d-flex justify-content-between mb-2">
                            <span>场次管理</span>
                            <a href="${pageContext.request.contextPath}/admin/showtimes" class="btn btn-sm btn-outline-primary">
                                <i class="fas fa-arrow-right"></i>
                            </a>
                        </div>
                        <div class="d-flex justify-content-between">
                            <span>返回首页</span>
                            <a href="${pageContext.request.contextPath}/admin/" class="btn btn-sm btn-outline-primary">
                                <i class="fas fa-arrow-right"></i>
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 操作提示 -->
        <div class="alert alert-info mt-4">
            <h6><i class="fas fa-info-circle me-2"></i>数据说明</h6>
            <ul class="mb-0">
                <li>统计数据每次访问时实时计算</li>
                <li>今日数据基于系统当前日期</li>
                <li>如需更详细的报表，可以考虑导出功能</li>
            </ul>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
